/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package customGuiControl.Listner;

import customGuiControl.ImagePanel;
import customGuiControl.TextPane;
import customGuiControl.roundButton;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import presentation.proportional.gui;

/**
 *
 * @author emilio
 */
public class wizardRollOverListner implements MouseListener {

    private String normal;
    private String over;
    private String pressed;
    private boolean boolEntered=false;
    private JFrame frameParent;
    private Cursor defCursor;
    private TextPane infoTextPane;
    private String infoText;
    private String previousInfoText;

    public wizardRollOverListner()
    {

    }
    public wizardRollOverListner(String normal, String over, String pressed)
    {
        this.normal=normal;
        this.over=over;
        this.pressed=pressed;
    }

    public wizardRollOverListner(String normal, String over, String pressed, gui parent, String infoText) {
        this(normal, over, pressed);
        this.setFrameParent(parent);
        
        this.infoText=infoText;
    }

    public void mouseClicked(MouseEvent e) {
         try{
            ((gui)this.getFrameParent()).buttonClicked(((ImagePanel)e.getSource()).getName());
        }
        catch(Exception exp){
            System.out.print(exp.toString());
        }
    }

    public void mousePressed(MouseEvent e) {
        ImagePanel target=(ImagePanel)e.getSource();
        if (this.boolEntered){
            target.setPathImg(this.pressed);
            target.getParent().repaint();
            target.repaint();
        }
    }

    public void mouseReleased(MouseEvent e) {
        ImagePanel target=(ImagePanel)e.getSource();
        if (this.boolEntered){
         target.setPathImg(this.over);
         target.getParent().repaint();
         target.repaint();
           
        }
    }

    public void mouseEntered(MouseEvent e) {
        this.changeCursor();
        ImagePanel target=(ImagePanel)e.getSource();
        this.boolEntered=true;
        target.setPathImg(this.over);
        target.getParent().repaint();
        target.repaint();

        this.infoTextPane=((gui)this.getFrameParent()).getInfoTextPane();
        this.previousInfoText=this.infoTextPane.getText();
        this.infoTextPane.setText(this.infoText);
        this.infoTextPane.setBold(true);
    }

    public void mouseExited(MouseEvent e) {
        this.changeCursor();
        ImagePanel target=(ImagePanel)e.getSource();
        this.boolEntered=false;
        target.setPathImg(this.normal);
        target.getParent().repaint();
        target.repaint();
        
        this.infoTextPane.setText(this.previousInfoText);
        this.infoTextPane.setBold(false);
    }

    public JFrame getFrameParent() {
        return frameParent;
    }

    public void setFrameParent(JFrame frameParent) {
        this.frameParent = frameParent;
    }

    public void changeCursor()
    {
        if(this.frameParent!=null)
        {
            if(this.defCursor==null)
            {
                this.defCursor=this.frameParent.getCursor();
                this.frameParent.setCursor(new Cursor(Cursor.HAND_CURSOR));
            }
            else
            {
                this.frameParent.setCursor(this.defCursor);
                this.defCursor=null;
            }
        }
    }

}
